import vxios from "@gatomis/vxios"

// index.js
Page({
    onShareAppMessage() {
        return {
            title: 'swiper',
            path: 'page/component/pages/swiper/swiper'
        }
    },

    data: {
        background: ['https://www.xqstudy.top/androidProjectGattaca/wx1.jpg',
            'https://www.xqstudy.top/androidProjectGattaca/wx2.jpg',
            'https://www.xqstudy.top/androidProjectGattaca/wx3.jpg'
        ],
        menu: [{
                name: '课程',
                image: 'https://www.xqstudy.top/androidProjectGattaca/icon_kecheng.png'
            },
            {
                name: '班级',
                image: 'https://www.xqstudy.top/androidProjectGattaca/icon_banji.png'
            },
            {
                name: '评测',
                image: 'https://www.xqstudy.top/androidProjectGattaca/icon_pingce.png'
            },
            {
                name: '培训',
                image: 'https://www.xqstudy.top/androidProjectGattaca/icon_peixun.png'
            },
            {
                name: '群组',
                image: 'https://www.xqstudy.top/androidProjectGattaca/icon_qunzu.png'
            },
        ],
        classes: [{
                class: '20003004',
                teacher: 'gattaca',
                num: '18',
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx2.jpg'
            },
            {
                class: '20003004',
                teacher: 'gattaca',
                num: '18',
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx4.jpg'
            },
            {
                class: '20003004',
                teacher: 'gattaca',
                num: '18',
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx3.jpg'
            },
            {
                class: '20003004',
                teacher: 'gattaca',
                num: '18',
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx1.jpg'
            }
        ],
        courseList: [{
                id: 1,
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx1.jpg',
            }, {

                id: 2,
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx2.jpg',
            },
            {
                id: 3,
                image: 'https://www.xqstudy.top/androidProjectGattaca/wx3.jpg'
            }
        ],
        indicatorDots: true,
        vertical: false,
        autoplay: false,
        interval: 2000,
        duration: 500
    },

    changeIndicatorDots() {
        this.setData({
            indicatorDots: !this.data.indicatorDots
        })
    },

    changeAutoplay() {
        this.setData({
            autoplay: !this.data.autoplay
        })
    },

    intervalChange(e) {
        this.setData({
            interval: e.detail.value
        })
    },

    durationChange(e) {
        this.setData({
            duration: e.detail.value
        })
    },

    goToCourseList(e) {
        wx.navigateTo({
            url: '../../pages/independent/course_list/course_list',
        })
    },

    goToClassList(e) {
        let myclass = e.currentTarget.dataset.myclass;
        wx.navigateTo({
            url: '../../pages/independent/class_list/class_list?myclass=' + myclass,
        })
    },

    onLoad(options) {

        vxios.get("/course/recommend").then(
            ({ data }) => {
                console.log({ data });
                this.setData({
                    courseList: data.data
                })
            }
        )
    },
    goToDetail(e) {
        let id = e.currentTarget.dataset.courseid;
        let stars = e.currentTarget.dataset.stars;
        wx.navigateTo({
            url: '../independent/course_detail/course_detail?Id=' + id + "&stars=" + stars,
        })
    },
})